All Questions
Tagged with text-formattingshell
19 questions
-1votes
1answer
75views
How can I format the output of a shell command into columns, but limit the number of columns created?
Say I run systemctl | grep running | column -t I get an output that looks like this: init.scope loaded active running System and Service Manager session-...
0votes
2answers
510views
Add commas in place of number with sed?
Trying to write a simple script to fetch ethereum price and format the response. Here is what I've tried: #!/bin/bash response=$(curl 'https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=...
0votes
1answer
85views
Line up text based on line contents
Is it possible to insert new lines in order to line up the contents of a file? I have: 1:1 Lorem ipsum dolor sit amet consectetur 1:1 This is sample text of varying length. adipiscing ...
0votes
1answer
68views
Merge multiple files and format output into columns with line wrap
I'm trying to show multiple files to a user within less. These files have relatively long lines and contain the same text but in different languages (differences in line length to be expected). ...
3votes
1answer
303views
align data by word into column
How can I align data into pretty columns relative to given word? For example, I have output of the route -n command: default via 172.20.99.254 dev eth0 87.33.17.71 dev tun0 scope link 89.223.15.12 ...
2votes
2answers
680views
Best way to pad stdin to desired length with NULL
I have the following requirement. I have an input stream that I need to truncate to a certain fixed length of bytes. I do not know the length of the input stream beforehand. If the stream is less in ...
0votes
1answer
2kviews
How do I format the output of SQL query row-wise
Below query gets me the value in a variable called result result=`mysql --user=root --password=password1 deployment --host=localhost -Ns -e "SELECT DATE_FORMAT(LAST_DAY(url_timestamp), '%M %Y') ...
0votes
4answers
490views
Formatting numbers in a specific column of a file inplace [closed]
I'm trying to format the Amount col to 2 decimal format like 1000 to 1000.00 I have a sample file like below Bank|Branch|Comment|Amount|Extra1|Extra2 xyz|we||100|| xyz|we||100.1|| xyz|we|paid for inv# ...
1vote
2answers
163views
How to remove unneccessary spaces from table output in shell while still keeping columns aligned?
Below command outputs a table of space delimited text, is there a tool to remove the unnecessary spacing here while still keeping the columns aligned? $ sudo ss -ltpn State Recv-Q Send-Q ...
4votes
4answers
50kviews
format the shell script output as a table
I am running a script in a loop which creates some data as per some logic and then displays output in some combination but the output I am getting is in new line Roll number : 187437366 ...
0votes
3answers
819views
How to convert pipe separated data to vertical format data
I have a scenario where want data to be stored in file in vertical format below is the data 143|2345|3456|4567|2345|3457|2019-12-28 12:00:01|2019-12-28 After applying my below logic my data is in ...
1vote
0answers
54views
Why are trailing line breaks stripped when used as an argument (for echo)? [duplicate]
When I run this… echo " fdsfsd dsfsdf " I really get the output of all these lines. However, if I use this output as an argument for echo again…: echo "$(echo " fdsfsd dsfsdf ")" …I do ...
0votes
2answers
3kviews
Concatenate strings with literal tab and new line character
I've a tab/space delimited file as: 31000BL 50014_10011 25467BL 50050_10003 47406BL 50001_10015 40831BL 50114_10006 40830BL 50114_10009 Two columns. I use a ...
6votes
3answers
1kviews
Print table with empty columns for consecutive delimiters
I typically use column to convert input into a table, eg: $ echo 'a\tb\tc\nd\te\tf' | column -t -s $'\t' a b c d e f However it collapses empty columns eg: $ echo 'a\tb\tc\nd\t\tf' | column -t -...
3votes
2answers
3kviews
How to present a command in multiple lines for instant copy/paste usage?
I am documenting some commands for future usage, some of them are too long and I want to document them in multiple lines for visualization, and then just copy and paste them for usage. For example: ...